package com.ews.onlineexchange.controller;

import java.util.ArrayList;
import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import com.ews.onlineexchange.model.Sector;
import com.ews.onlineexchange.service.EntityQuery;

@Model
public class SectorList extends EntityQuery<Sector> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public SectorList() {
		setMaxResults(MAX_RESULTS_NORMAL);
		setOrder("sno ASC");		
	}

	@Override
	protected List<Predicate> getRestrictions(CriteriaBuilder cb, Root<Sector> entity) {
		List<Predicate>  restrictions =  new ArrayList<Predicate>();
		restrictions.add(cb.equal(entity.get("delFlag"), Sector.DEL_FLAG_NORMAL));
		restrictions.add(cb.like(entity.get("sectorName"), getStringRestriction(getParameterValues().get("sectorName"))));
		return restrictions;
	}
	
	
}
